package pub.guoxin.oops.common.base.cors;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by guoxin on 17-12-6.
 */
@Configuration
public class CorsConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedHeaders("*")
                // 它需要前后端一起开启，开启之后就能够读写浏览器的Cookies，但是这个Cookies是完全由你要请求站点控制的
                .allowedMethods("*")
//                .allowCredentials(false)
                .maxAge(3600);
    }
}
